package com.toonly.defaultvalues;

import com.toonly.defaultvalues.framework.ASetter;
import com.toonly.defaultvalues.framework.GeneratedValue;
import com.toonly.defaultvalues.framework.IDefaultValueGenerator;
import com.toonly.defaultvalues.framework.IGeneratedValue;

public class IntDefaultValueGenerator extends ASetter<Main.Context> implements IDefaultValueGenerator<Main.Context> {

    public static final Integer DEFAULT_INT = 1;

    @Override
    public IGeneratedValue generate() {
        Class<?> clazz = this.source.getClazz();

        if (this.source.getType() instanceof Class) {
            clazz = (Class<?>) this.source.getType();
        }

        if (clazz == Integer.class || clazz == int.class) {
            return new GeneratedValue(true, DEFAULT_INT);
        }

        return new GeneratedValue(false, null);
    }
}
